<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件对象</title>
</head>
<body>
    <input type="text">

    <script>
        const input = document.querySelector('input')

        input.addEventListener('keydown', function(e){
            console.log(e.key);
            if (e.key === 'Enter') {
                console.log('回车键被按下');
            }
        })
    </script>
</body>
</html>